const db = require('../../db/index')
const getInfo = (req, res) => {
    const { nickname } = req.body.data
    const sql = `select * from t_everyone where name like '%${nickname}%'`
    db.query(sql, (err, result) => {
        if (err) return res.send({ code: 500, message: err.message })
        res.send({
            code: 200,
            msg: '获取列表成功',
            data: result[0]
        })
    })
}

const updateInfo = (req, res) => {
    const { id, data } = req.body.data
    const sql = `update t_everyone set ? where id=${id}`
    db.query(sql, [data], (err, result) => {
        if (err) return res.send({ code: 500, msg: err })
        res.send({
            code: 200,
            msg: '修改成功'
        })
    })
}


module.exports = {
    getInfo,
    updateInfo
}